package marchsoft.modules.security.entity.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
import marchsoft.modules.four.h5.entity.dto.EStudentDTO;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;

/**
 * @ClassName JwtFrontUserDTO
 * @Author ZhuGuangLiang <786945363@qq.com>
 * @Date 2022/04/04 09:18
 */

@Getter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class JwtFrontUserDTO implements UserDetails, Serializable {
	private EStudentDTO user;

	@Override
	@JsonIgnore
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return null;
	}

	@Override
	@JsonIgnore
	public String getPassword() {
		return user.getPassword();
	}

	@Override
	@JsonIgnore
	public String getUsername() {
		return user.getStudentNum();
	}

	@JsonIgnore
	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@JsonIgnore
	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@JsonIgnore
	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@Override
	@JsonIgnore
	public boolean isEnabled() {
		return !user.getDeleted();
	}
}
